export interface ISubscribe {
    subscribe:(topic: string)=>void
    unsubscribe:(topic: string)=>void
    receive:(message:string)=>void
}
import { Broker } from "./Broker";

export class SubScribe implements ISubscribe{
    private broker:Broker;
    private id:number;
    constructor(id,broker:Broker){
        this.id = id
        this.broker = broker
    }
    subscribe(topic: string): void {
        this.broker.subscribe(topic,this)
    }

    unsubscribe(topic:string){
        this.broker.unsubscribe(topic,this)
    }

    receive(message: string){
        console.log("收到消息--》",message,this.id)
    }
}